import { Component } from "react"
import Com2_emit2 from "./components/Com2_emit2"

export default class Page2 extends Component {
  constructor() {
    super()
    this.state = {
      num: 1
    }
  }

  onAdd(value) {
    this.setState({
      num: this.state.num + value
    })
  }

  render() {
    return (
      <div>
        {this.state.num}
        <Com2_emit2 onAdd={this.onAdd.bind(this)} />

        {/*  其他方式*/}
        <Com2_emit2
          onAdd={(val) => {
            this.onAdd(val)
          }}
        />
      </div>
    )
  }
}
